<!--
  ~ Copyright (c) 2020 the original author or authors
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      https://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  ~ or implied. See the License for the specific language governing
  ~ permissions and limitations under the License.
  -->
<div class="main">
  <div class="add-subject">
    <button mat-flat-button color="primary" (click)="addSubject.emit()">
      {{ 'manage_collection.left_side.add_subject' | translate }}
    </button>
  </div>
  <div class="search">
    <app-search-table (inputSearch)="onSearch($event)" searchPlaceholder="{{ 'manage_collection.left_side.search' | translate }}">
    </app-search-table>
  </div>
  <div class="subjects">
    <div class="subjects--spinner">
      <app-spinner *ngIf="isPending"></app-spinner>
    </div>
    <ng-container *ngIf="!isPending">
      <ul class="select">
        <li
          *ngFor="let subject of subjectsList | subjectFilter: search"
          (click)="selectedSubject.emit(subject)"
          class="option"
          [attr.selected]="subject === currentSubject"
          [ngStyle]="{ 'pointer-events': subject === currentSubject ? 'none' : 'auto' }"
        >
          <div class="avatar">
            <mat-icon class="material-icon" [ngClass]="{ 'selected-icon': subject === currentSubject }"> account_circle </mat-icon>
            <div class="name">{{ subject }}</div>
          </div>
        </li>
      </ul>
    </ng-container>
  </div>
</div>
